package
{
	import flash.display.Sprite;
	import flash.events.Event;
	
	import widget.common.event.LoadDataEvent;
	import widget.common.tools.XMLFileLoader;
	
	[SWF(frameRate="25",width="1000",height="600")]
	public class WidgetMain extends Sprite{
		
		protected var configPath:String = "";
		public function WidgetMain()
		{
			super();
			this.addEventListener(Event.ADDED_TO_STAGE,addStageHandler);
		}
		
		private function addStageHandler(event:Event):void
		{
			init();
			this.removeEventListener(Event.ADDED_TO_STAGE,addStageHandler);
		}
		
		protected function init():void
		{
			
		}
		
		protected function loadXMLConfig():void
		{
			if(configPath == "") return;
			XML.ignoreComments = true;
			XML.ignoreWhitespace = true;
			var xmlLoader:XMLFileLoader = new XMLFileLoader();
			xmlLoader.addEventListener(LoadDataEvent.COMPLETE_LOADER,loadCompleteHandler);
			xmlLoader.loadData(configPath);
		}
		
		protected function parseConfigXML(xml:String):void
		{
			
		}
		
		private function loadCompleteHandler(event:LoadDataEvent):void
		{
			var xmlStr:String = event.getTxtFile();
			parseConfigXML(xmlStr);
			var xmlLoader:XMLFileLoader = event.currentTarget as XMLFileLoader;
			xmlLoader.clear();
			xmlLoader.removeEventListener(LoadDataEvent.COMPLETE_LOADER,loadCompleteHandler);
		}
	}
}